﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using JoyTalq.Core.Business.Persistence;
using JoyTalq.Core.Business.Domain;

namespace JoyTalq.Core.Business.Service.Impl
{
    public class BusinessService : IBusinessService
    {
        public IBusinessDao BusinessDao { get; set; }

        /// <summary>
        /// 新增企業資料主檔
        /// </summary>
        /// <param name="customerVO">被新增的企業資料主檔</param>
        /// <returns>新增後的企業資料主檔</returns>
        public CustomerVO CreateCustomer(CustomerVO customerVO)
        {
            return BusinessDao.CreateCustomer(customerVO);
        }

        /// <summary>
        /// 更新企業資料主檔
        /// </summary>
        /// <param name="customerVO">被更新的企業資料主檔</param>
        /// <returns>更新後的企業資料主檔</returns>
        public CustomerVO UpdateCustomer(CustomerVO customerVO)
        {
            return BusinessDao.UpdateCustomer(customerVO);
        }

        /// <summary>
        /// 刪除企業資料主檔
        /// </summary>
        /// <param name="customerVO">被刪除的企業資料主檔</param>
        public void DeleteCustomer(CustomerVO customerVO)
        {
            BusinessDao.DeleteCustomer(customerVO);
        }

        /// <summary>
        /// 取得企業資料主檔 By 識別碼
        /// </summary>
        /// <param name="customerId">識別碼</param>
        /// <returns>企業資料主檔</returns>
        public CustomerVO GetCustomerById(Guid customerId)
        {
            return BusinessDao.GetCustomerById(customerId);
        }

        /// <summary>
        /// 取得企業資料主檔清單
        /// </summary>
        /// <param name="queryString">搜尋語法，用Where...order by ...</param>
        /// <returns>企業資料主檔清單</returns>
        public IList<CustomerVO> GetCustomerList(string queryString)
        {            
            return BusinessDao.GetCustomerList(queryString);
        }

        /// <summary>
        /// 取得企業資料主檔清單
        /// </summary>
        /// <param name="queryString">搜尋語法，用Where...order by ...</param>
        /// <returns>企業資料主檔清單</returns>
        public IList<CustomerVO> GetCustomerList(string queryString, int pageIndex, int pageSize)
        {
            return BusinessDao.GetCustomerList(queryString, pageIndex, pageSize);
        }

        /// <summary>
        /// 取得全部的企業資料主檔清單
        /// </summary>
        /// <returns>全部的企業資料主檔清單</returns>
        public IList<CustomerVO> GetAllCustomerList()
        {
            return BusinessDao.GetAllCustomerList();
        }

        /// <summary>
        /// 取得全部的企業資料主檔清單
        /// </summary>
        /// <param name="pageIndex">分頁索引</param>
        /// <param name="pageSize">分頁大小</param>
        /// <param name="sortField">排序欄位</param>
        /// <param name="sortDesc">升降冪排序</param>
        /// <returns>全部的企業資料主檔清單</returns>
        public IList<CustomerVO> GetAllCustomerList(int pageIndex, int pageSize, string sortField, bool sortDesc)
        {
            if (string.IsNullOrEmpty(sortField))
            {
                return BusinessDao.GetAllCustomerList(pageIndex, pageSize);
            }
            
            return BusinessDao.GetAllCustomerList(pageIndex, pageSize, sortField, sortDesc);
        }

        /// <summary>
        /// 新增品牌資料主檔
        /// </summary>
        /// <param name="brandVO">被新增的品牌資料主檔</param>
        /// <returns>新增後的品牌資料主檔</returns>
        public BrandVO CreateBrand(BrandVO brandVO)
        {
            return BusinessDao.CreateBrand(brandVO);
        }

        /// <summary>
        /// 更新品牌資料主檔
        /// </summary>
        /// <param name="brandVO">被更新的品牌資料主檔</param>
        /// <returns>更新後的品牌資料主檔</returns>
        public BrandVO UpdateBrand(BrandVO brandVO)
        {
            return BusinessDao.UpdateBrand(brandVO);
        }

        /// <summary>
        /// 刪除品牌資料主檔
        /// </summary>
        /// <param name="brandVO">被刪除的品牌資料主檔</param>
        public void DeleteBrand(BrandVO brandVO)
        {
            BusinessDao.DeleteBrand(brandVO);
        }

        /// <summary>
        /// 取得品牌資料主檔 By 識別碼
        /// </summary>
        /// <param name="brandId">識別碼</param>
        /// <returns>品牌資料主檔</returns>
        public BrandVO GetBrandById(Guid brandId)
        {
            return BusinessDao.GetBrandById(brandId);
        }
    }
}
